@extends('layouts.layout')
@section('content')

{{--图片上传--}}
<script src="{{asset('upload/js/vendor/jquery.ui.widget.js')}}"></script>
<script src="{{asset('upload/js/jquery.iframe-transport.js')}}"></script>
<script src="{{asset('upload/js/jquery.fileupload.js')}}"></script>
<script src="{{asset('upload/js/uploadImg.js')}}"></script>
{{--/图片上传--}}

<div class="header">
    @include('layouts.count')

    <h1 class="page-title">文章管理</h1>
    <ul class="breadcrumb">
        <li  class="active">添加文章 </li>
    </ul>

</div>


        <ul class="nav nav-tabs">
            <li class="active"><a href="#home" data-toggle="tab">Profile</a></li>
            {{--<li class=""><a href="#profile" data-toggle="tab">Password</a></li>--}}
        </ul>

        <div class="row">
            <div class="col-md-8">
                <br>
                <div id="myTabContent" class="tab-content">
                    <div class="tab-pane active" id="home">
                        <form id="tab" action="{{url('article')}}" method="post">
                            {{csrf_field()}}

                            <div class="form-group">
                                <label>文章类别</label>
                                <select name="category" id="DropDownTimezone" class="form-control">
                                    @if($user_id=='1')
                                        <option value="1">新闻资讯</option>
                                        <option value="2">公告</option>
                                        <option value="3">重要信息</option>
                                        <option value="4">人才政策</option>
                                        <option value="5">产业政策</option>
                                        @elseif($user_id!='1')
                                            <option value="1">新闻资讯</option>
                                        @endif
                                </select>
                                <input type="hidden" name="category" value="1" id="category">
                            </div>



                            <div class="form-group">
                                <label>标题*</label>
                                <input type="text" value="" class="form-control" name="title">
                            </div>



                            <div class="form-group">
                                <label>描述</label></br>
                                <textarea name="desc" style="width: 100% ; height: 80px"> </textarea>
                            </div>

                            <div class="form-group">
                                <label>上传图片*</label></br>

                                    <input class="form-control" id="field-1" type="file" onclick="fileupload($(this),$(this).closest('div'),'avatar',1,'fileuplade');" name="file" data-url="{{url('admin/upload')}}">
                                    <div class="progress">
                                        <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
                                        </div>
                                    </div>
                                    <input type="hidden" id="table" value="" />
                                    <input type="hidden" id="key1" value="" />
                                    <input type="hidden" id="key2" value="" />
                                    <section class="gallery-env">
                                        <div class="row">
                                            <!-- Gallery Album Optipns and Images -->
                                            <div class="col-sm-12">
                                                <!-- Album Images -->
                                                <div class="album-images row" id="fileuplade">
                                                    <!-- Album Image -->
                                                </div>
                                            </div>
                                        </div>
                                    </section>
                                </div>

                                <div class="form-group">
                                    <label>内容</label>

                                    @include('UEditor::head')
                                    <script id="ueditor" name="content" type="text/plain" style="width: 100%; height:300px">编辑你的内容 </script>

                                    </div>
                            </div>





                            {{--<div class="form-group">--}}
                                {{--<label>Time Zone</label>--}}
                                {{--<select name="DropDownTimezone" id="DropDownTimezone" class="form-control">--}}
                                    {{--<option value="-12.0">(GMT -12:00) Eniwetok, Kwajalein</option>--}}
                                {{--</select>--}}
                            {{--</div>--}}
                        </form>
                    </div>

                   {{--<div class="tab-pane" id="profile">--}}

                        {{--<form id="tab2">--}}
                            {{--<div class="form-group">--}}
                                {{--<label>New Password</label>--}}
                                {{--<input type="password" class="form-control">--}}
                            {{--</div>--}}
                            {{--<div>--}}
                                {{--<button class="btn btn-primary">Update</button>--}}
                            {{--</div>--}}
                        {{--</form>--}}
                    {{--</div>--}}
                {{--</div>--}}

                <div class="btn-toolbar list-toolbar">
                    <button class="btn btn-primary" id="btn"><i class="fa fa-save"></i> Save</button>
                    {{--<a href="#myModal" data-toggle="modal" class="btn btn-danger">Delete</a>--}}
                </div>
            </div>
        </div>

        <div class="modal small fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h3 id="myModalLabel">Delete Confirmation</h3>
                    </div>
                    <div class="modal-body">

                        <p class="error-text"><i class="fa fa-warning modal-icon"></i>Are you sure you want to delete the user?</p>
                    </div>
                    <div class="modal-footer">
                        <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>
                        <button class="btn btn-danger" data-dismiss="modal">Delete</button>
                    </div>
                </div>
            </div>
        </div>




</div>

        {{--<link rel="stylesheet" href="{{ URL::asset('/laravel-u-editor/themes/default/css/ueditor.css') }}">--}}
        {{--<!-- 引用jquery -->--}}
        {{--<script src="{{URL::asset('/laravel-u-editor/third-party/jquery-1.10.2.js')}}"></script>--}}
        {{--<!-- 配置文件 -->--}}
        {{--<script type="text/javascript" src="{{URL::asset('/laravel-u-editor/ueditor.config.js')}}"></script>--}}
        {{--<!-- 编辑器源码文件 -->--}}
        {{--<script type="text/javascript" src="{{URL::asset('/laravel-u-editor/ueditor.all.js')}}"></script>--}}
        {{--<!-- 语言包文件 -->--}}
        {{--<script type="text/javascript"--}}
                {{--src="{{ URL::asset('/laravel-u-editor/lang/zh-cn/zh-cn.js') }}"></script>--}}

    {{--<script  type="text/plain"  id="ueditor"  name="content" style="width: 600px; hegith:200px"></script>--}}

    <script type="text/javascript">
            var ue=UE.getEditor("ueditor");
            ue.ready(function(){
                //因为Laravel有防csrf防伪造攻击的处理所以加上此行
                ue.execCommand('serverparam','_token','{{ csrf_token() }}');
            });
    </script>


                                <script type="text/javascript">

                                    $("#btn").click(function(){    // 提交按钮触发事件




                                        var tourl = $("#tab").attr("action");    // 获取 表单的 提交地址
                                        // 序列化 表单数据 后提交 ，太简洁了
                                        $.post(tourl,$("#tab").serialize(),function(data){


                                            //直接返回首页
                                            /*layer.msg(data['info'],5,data['status'],function(){
                                                location.href = "{:U('Index/index')}"; //自动关闭后返回首页
                                            });*/
                                            //确定返回首页还是再次添加


                                            if(data.status_code==200){
                                                layer.confirm(data.msg, {
                                                    btn: ['返回首页','继续添加'] //按钮
                                                }, function(){
                                                    location.href = "{{url('article')}}";
//                                                layer.msg('的确很重要', {icon: 1});
                                                }, function(){
                                                    location.reload();
//                                                layer.msg('也可以这样', {
//                                                    time: 20000, //20s后自动关闭
//                                                    btn: ['明白了', '知道了']
//                                                });
                                                });
                                            }else{
                                                layer.msg(data.msg,{icon:5},function(){
                                                    time:1000;
                                                })
                                            }

                                        });
                                    });

                                    /**
                                     * seletor 赋值函数
                                     */

                                    $('#DropDownTimezone').change(function(){
                                       $('#category').val($(this).val());
                                    });


                                </script>






@stop




